import request from '@/utils/request.js';

// 角色列表
export const rolesList = () => {
  return request({
    method: 'GET',
    url: 'roles'
  });
};

// 添加角色
export const addRolesApi = (data) => {
  return request({
    method: 'POST',
    url: 'roles',
    data
  });
};

// 查询角色
export const getRolesApi = (id) => {
  return request({
    method: 'GET',
    url: `roles/${id}`
  });
};

// 编辑角色
export const editRolesApi = (data) => {
  return request({
    method: 'PUT',
    url: `roles/${data.roleId}`,
    data
  });
};

// 删除角色
export const deleteRolesApi = (roleId) => {
  return request({
    method: 'DELETE',
    url: `roles/${roleId}`
  });
};

// 获取所有权限列表
export const getRightsList = (type) => {
  return request({
    method: 'GET',
    url: `rights/${type}`
  });
};

// 删除角色指定权限
export const deleteRolesRight = (roleId, rightId) => {
  return request({
    method: 'DELETE',
    url: `roles/${roleId}/rights/${rightId}`
  });
};

// 角色授权
export const showRolesRights = (roleId, data) => {
  return request({
    method: 'POST',
    url: `roles/${roleId}/rights`,
    data
  });
};

